package com.cx.factory;

public interface IAbstractFactory {
    /**
     * 创建对象方法
     * @return
     */
    //创建正方形对象
    Shape createSquareBean();
    //创建三角形对象
    Shape createTriangleBean();
    //创建其他图形对象
    Shape createOtherBean();
}

class IAbstractFactoryImpl implements IAbstractFactory{
    @Override
    public Shape createSquareBean() {
        return new Square();
    }
    @Override
    public Shape createTriangleBean() {
        return new Triangle();
    }
    @Override
    public Shape createOtherBean() {
        return new Other();
    }
}

class IAbstractFactoryTest{
    public static void main(String[] args) {

        IAbstractFactory iAbstractFactory = new IAbstractFactoryImpl();
        Shape triangleBean = iAbstractFactory.createTriangleBean();
        triangleBean.draw();
        Shape squareBean = iAbstractFactory.createSquareBean();
        squareBean.draw();
        Shape otherBean = iAbstractFactory.createOtherBean();
        otherBean.draw();
    }
}
